/**
 * Copyright (c) 2018-present, Chen Guodong
 * All rights reserved.
 *
 * @flow
 */


<template>
  <section>
    <ul v-if="data.flows && data.flows.elements && data.flows.elements.length>0">
      <li class="remarkBox mar-bot-12" v-for="(item, index) in data.flows.elements" :key="index">
        <!-- <Select :ref="item.model" :data="item" v-if="item.type === 'select'"></Select> -->
        <InputForm :ref="item.name" :data="item" v-if="item.type === 'text'"></InputForm>
      </li>
    </ul>
    <!-- <button @click="submit">提交</button> -->
  </section>
</template>

<script>
import InputForm from "../../components/Form/InputForm";

export default {
  props: {
    data: Object
  },
  data() {
    return {};
  },
  methods: {
    submit() {
      // label: "文本一"
      // layers: 0
      // name: "amount"
      // table: "db_nk_prereport"
      // type: "text"
      // value: "100"
      console.log("submit");
      let self = this;
      let elements = this.data.flows.elements;
      let result = new Array(); //保存选中的数据
      result['forms'] = [];
      result['formTables'] = [];
      if (elements && elements.length > 0) {
        elements.map((item, index) => {
          if(!result['forms'][item.layers]){
            result['forms'][item.layers] = {};
          }
          result['forms'][item.layers][item.name] = self.$refs[item.name][0].result;
          result['formTables'][item.layers] = self.$refs[item.name][0].table
        });
      }
      console.log('result', result)
    }
  },
  components: {
    InputForm
  }
};
</script>

<style lang='less' scoped>
@import "../../util/themt.less";

.remarkBox {
  border-radius: 4px;
  overflow: hidden;
  .boxShadow();
}

.mar-bot-12 {
  margin-bottom: 8px;
  background: #fff;
}
</style>
